// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlGetOverallBucketsRequestParameters : RequestParameters<MlGetOverallBucketsRequestParameters>
	{
	}

	public sealed partial class MlGetOverallBucketsRequest : PlainRequestBase<MlGetOverallBucketsRequestParameters>
	{
		public MlGetOverallBucketsRequest(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetOverallBuckets;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("allow_no_match")]
		public bool? AllowNoMatch { get; set; }

		[JsonInclude]
		[JsonPropertyName("bucket_span")]
		public Elastic.Clients.Elasticsearch.Duration? BucketSpan { get; set; }

		[JsonInclude]
		[JsonPropertyName("end")]
		public DateTimeOffset? End { get; set; }

		[JsonInclude]
		[JsonPropertyName("exclude_interim")]
		public bool? ExcludeInterim { get; set; }

		[JsonInclude]
		[JsonPropertyName("overall_score")]
		public Union<double?, string?>? OverallScore { get; set; }

		[JsonInclude]
		[JsonPropertyName("start")]
		public DateTimeOffset? Start { get; set; }

		[JsonInclude]
		[JsonPropertyName("top_n")]
		public int? TopN { get; set; }
	}

	public sealed partial class MlGetOverallBucketsRequestDescriptor : RequestDescriptorBase<MlGetOverallBucketsRequestDescriptor, MlGetOverallBucketsRequestParameters>
	{
		internal MlGetOverallBucketsRequestDescriptor(Action<MlGetOverallBucketsRequestDescriptor> configure) => configure.Invoke(this);
		public MlGetOverallBucketsRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlGetOverallBucketsRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningGetOverallBuckets;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlGetOverallBucketsRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		private bool? AllowNoMatchValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? BucketSpanValue { get; set; }

		private DateTimeOffset? EndValue { get; set; }

		private bool? ExcludeInterimValue { get; set; }

		private Union<double?, string?>? OverallScoreValue { get; set; }

		private DateTimeOffset? StartValue { get; set; }

		private int? TopNValue { get; set; }

		public MlGetOverallBucketsRequestDescriptor AllowNoMatch(bool? allowNoMatch = true)
		{
			AllowNoMatchValue = allowNoMatch;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor BucketSpan(Elastic.Clients.Elasticsearch.Duration? bucketSpan)
		{
			BucketSpanValue = bucketSpan;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor End(DateTimeOffset? end)
		{
			EndValue = end;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor ExcludeInterim(bool? excludeInterim = true)
		{
			ExcludeInterimValue = excludeInterim;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor OverallScore(Union<double?, string?>? overallScore)
		{
			OverallScoreValue = overallScore;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor Start(DateTimeOffset? start)
		{
			StartValue = start;
			return Self;
		}

		public MlGetOverallBucketsRequestDescriptor TopN(int? topN)
		{
			TopNValue = topN;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AllowNoMatchValue.HasValue)
			{
				writer.WritePropertyName("allow_no_match");
				writer.WriteBooleanValue(AllowNoMatchValue.Value);
			}

			if (BucketSpanValue is not null)
			{
				writer.WritePropertyName("bucket_span");
				JsonSerializer.Serialize(writer, BucketSpanValue, options);
			}

			if (EndValue is not null)
			{
				writer.WritePropertyName("end");
				JsonSerializer.Serialize(writer, EndValue, options);
			}

			if (ExcludeInterimValue.HasValue)
			{
				writer.WritePropertyName("exclude_interim");
				writer.WriteBooleanValue(ExcludeInterimValue.Value);
			}

			if (OverallScoreValue is not null)
			{
				writer.WritePropertyName("overall_score");
				JsonSerializer.Serialize(writer, OverallScoreValue, options);
			}

			if (StartValue is not null)
			{
				writer.WritePropertyName("start");
				JsonSerializer.Serialize(writer, StartValue, options);
			}

			if (TopNValue.HasValue)
			{
				writer.WritePropertyName("top_n");
				writer.WriteNumberValue(TopNValue.Value);
			}

			writer.WriteEndObject();
		}
	}
}